window.onload=function ()
{
    var vue=new Vue({
        el:"#app",
        data:{
            sellerList:[],
            seller:{},
            searchSeller:{status:'0'},
            pages:0,
            current:1,
            ids:[],
            checked:false
        },
        methods:{
            findByPage:function (current)
            {
                axios.get("/seller/findByPage?page="+current,{params:this.searchSeller}).then(function (response)
                {
                    vue.pages=response.data.pages;
                    vue.sellerList=response.data.rows;
                    vue.current=current;
                    vue.ids=[];
                })
            },
            showDetail:function (ele)
            {
                this.seller=ele;
            },
            checkAll:function (event)
            {
                this.ids=[];
                if(event.target.checked)
                {
                    for(var i=0; i<this.sellerList.length; i++)
                    {
                        this.ids.push(this.sellerList[i].sellerId);
                    }
                }
            },
            updateStatus:function (sellerId, status)
            {
                axios.get("/seller/updateStatus?sellerId="+sellerId+'&status='+status).then(function (response)
                {
                    if(response.data)
                    {
                        vue.findByPage(vue.current);
                    }
                    else
                    {
                        alert("审核失败！");
                    }
                })
            }
        },
        created:function ()
        {
            this.findByPage(this.current);
        },
        updated:function ()
        {
            this.checked = (this.ids.length == this.sellerList.length);
            /*if(this.sellerList.length==0)
            {
                this.checked=false;
            }*/
        }
    })
};